package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduSchoolPlan.EduSchoolPlanKeyVO;
import com.jwsoft.manager.common.vo.eduSchoolPlan.EduSchoolPlanQueryVO;
import com.jwsoft.manager.common.vo.eduSchoolPlan.EduSchoolPlanVO;
import com.jwsoft.manager.core.integration.EduSchoolPlanIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 学校招生计划表网关
 *
 * @author chenzh
 * @since 2023-02-10
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "学校招生计划表", description = "学校招生计划表")
public class EduSchoolPlanController {

    @Autowired
    public EduSchoolPlanIntegration eduSchoolPlanIntegration;

    @Operation(summary = "学校招生计划表分页查询",description = "学校招生计划表分页查询")
    @PostMapping(value = "/school_plan0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduSchoolPlanVO>> getList(@RequestBody @Validated EduSchoolPlanQueryVO vo) {
        return AppResponse.successData(eduSchoolPlanIntegration.getList(vo));
    }

    @Operation(summary = "学校招生计划表根据主键查询详情",description = "学校招生计划表根据主键查询详情")
    @PostMapping(value = "/school_plan0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolPlanVO> getById(@RequestBody @Validated EduSchoolPlanKeyVO vo) {
        return AppResponse.successData(eduSchoolPlanIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学校招生计划表新增",description = "学校招生计划表新增")
    @PostMapping(value = "/school_plan0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolPlanVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduSchoolPlanVO vo) {
        return AppResponse.successData(eduSchoolPlanIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学校招生计划表修改",description = "学校招生计划表修改")
    @PostMapping(value = "/school_plan0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolPlanVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduSchoolPlanVO vo) {
        return AppResponse.successData(eduSchoolPlanIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学校招生计划表删除",description = "学校招生计划表删除")
    @PostMapping(value = "/school_plan0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduSchoolPlanKeyVO vo) {
        eduSchoolPlanIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
}
